const cloud = require('wx-server-sdk')
    cloud.init({
      env: cloud.DYNAMIC_CURRENT_ENV
    })
    const db = cloud.database()
    const _ = db.command
    exports.main = async (event, context) => {
      var _id = event._id ? event._id : null;
      var data = event.data ? event.data : null;
      var card = event.card ? event.card : null;
      console.log(_id+"===="+data)
      try {
        return await db.collection('th_cards').where({
          _id: _id
        }).update({
          // data 字段表示需新增的 JSON 数据
          data: {
            cardcode: data.cardcode,
            cardtype: card[0].code,
            thcode: data.thcode,
          },
        })
      } catch(e) {
        console.error(e)
      }
    }